
//== 进入动画 ==
function run(obj,sty){//添加动画样式
    $(obj).css("animation",sty+" 2s 1");
    $(obj).css("transition","all 0.8s");
}
function runOut(obj){//删除动画样式
    $(obj).css("animation","");
    $(obj).css("transition","");
}

//== 响应式内容 ==
$(function (){
    //rem
    var c=()=>{//箭头表达式（函数）
        let w=document.documentElement.clientWidth;//获取设备宽度
        // alert(w);
        let n;
        n=(20*(w/1500)>27?27+"px":(20*(w/1500)+"px"));//计算需要的大小
        n=(20*(w/1500)<16?16+"px":(20*(w/1500)+"px"));//(视口缩小时)
        document.documentElement.style.fontSize=n;//改变根字体
    }
    window.addEventListener("load",c);//初始化效果
    window.addEventListener("resize",c);//当屏幕尺寸发生改变时(视口缩放也会使尺寸改变)


    // 判断是手机端还是PC端
    if(/Mobi|Android|iPhone|Pixel|Samung|Surface Duo|iPad/i.test(navigator.userAgent) && window.screen.width < 920){
        //手机
        //在这里可以引外部CSS(媒体查询)
    }else{
        //PC
        // 浏览器缩放
        //用图片替换来解决字体放大问题·奇淫巧计（ -_-`）
        let meg=0;
        let zoom=()=>{  //=>函数：在这里zoom并不会接受返回值，可能是版本限制
            meg = detectZoom();
            let sad = $('#sad');
            if(meg > 132){
                // console.log(sad.src);
                if(sad.src === undefined){
                    $(sad).css("width","100%");//加样式
                    $(sad).css("height","100%");
                }
            }else{
                $(sad).css("width","0.1%");//加样式
                $(sad).css("height","0.1%");
            }
        }
        window.addEventListener("resize",zoom);//当屏幕尺寸发生改变时(视口缩放也会使尺寸改变)
        let scaleDiv_text=()=>{
            let screenWith = window.innerWidth;
            let elem,count;
            if(screenWith  <  750){
                count = screenWith;
                count /= 750;//计算前后变化比例
                count =  1 - count;//实现比例变大，count值减小
                count = count/0.023;
                count = Math.ceil(count);//向上取整（可不加）
                elem = $('.card');
                $(elem).css("height","28.3%");
                elem = $('.card1');
                $(elem).css("margin-top","5%");
                elem = $('.card2');
                $(elem).css("margin-top",count+"%");
            }
            else if(screenWith < 1203){
                elem = document.getElementById('showIntro');
                if(elem){//showIntro存在
                    // alert(elem);
                }
                else{
                    elem = $('#megOfFarm');
                    $('<div id="showIntro" onmouseover="showIntroduction()" onmouseleave="hideIntroduction()">\n' +
                        '            <svg t="1673864241987" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3941" width="32" height="32"><path d="M191.94 512.06m-75 0a75 75 0 1 0 150 0 75 75 0 1 0-150 0Z" fill="#1296db" p-id="3942"></path><path d="M514.34 512.06m-75 0a75 75 0 1 0 150 0 75 75 0 1 0-150 0Z" fill="#1296db" p-id="3943"></path><path d="M832.06 512.06m-75 0a75 75 0 1 0 150 0 75 75 0 1 0-150 0Z" fill="#1296db" p-id="3944"></path></svg>\n' +
                        '          </div>').appendTo(elem);
                }

            }
            else {//恢复原始样式
                elem = $('.card');
                $(elem).css("height","25%");
                elem = $('.card1');
                $(elem).css("margin-top","-4%");
                elem = $('.card2');
                $(elem).css("margin-top","-8%");

                elem = document.getElementById('showIntro');
                elem.parentNode.removeChild(elem);

                hideIntroduction();
            }
        }
        window.addEventListener("resize",scaleDiv_text);

        //移除fill否则在fill后的fullpage.js将失效
        let obj;
        //试过了，好像只能用原生的选择器
        obj = document.getElementById('fill01');
        obj.parentNode.removeChild(obj);
        obj = document.getElementById('fill02');
        obj.parentNode.removeChild(obj);

    }
})
function hideIntroduction(){
    let elem = $('#highLevel');
    $(elem).css("opacity","0");
    $(elem).css("z-index","-1");
}
function showIntroduction(){
    let elem = $('#highLevel');
    $(elem).css("opacity","1");
    $(elem).css("z-index","1");
    elem.on('mouseout',function (){
        $(elem).css("opacity","0");
        $(elem).css("z-index","-1");
    });
}

//获取浏览器缩放比例
function detectZoom() {
    let ratio = 0,
        screen = window.screen,//获取屏幕
        ua = navigator.userAgent.toLowerCase();//判断登陆端是pc还是手机

    if (window.devicePixelRatio !== undefined) {
        ratio = window.devicePixelRatio;//浏览器当前缩放比
    }
    else if (~ua.indexOf('msie')) {
        if (screen.deviceXDPI && screen.logicalXDPI) {
            ratio = screen.deviceXDPI / screen.logicalXDPI;
        }
    }
    else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
        ratio = window.outerWidth / window.innerWidth;
    }

    if (ratio) {
        ratio = ratio * 100 - 25;//计算得到的结果需要x100才可以和现实的比例相对应
                                 //减25是因为在edge中（也可能是电脑屏幕尺寸的原因），计算得125%时对应的浏览器视口为100%
        return ratio;
    }
}

$(function (){
    // var a = setInterval(function (){alert(window.innerWidth + " ; " + window.innerHeight)},5000);
})